using Sustainalytics.ESG.Entities;
using Sustainalytics.Synchronization.Validation.ValidationRules.Comprehensive;
using Xunit;

namespace Sustainalytics.Synchronization.Validation.Tests
{
    [Trait("Category", "Unit")]
    public class OverallScore
    {
        private readonly RPCompanyESGComputationResult fake = new RPCompanyESGComputationResult
        {
            OverallPerformance = new RPPerformance { Score = 10 }
        };

        public class RedRule_should_ : OverallScore
        {
            private readonly ScoreChangeRedRule _sut = new ScoreChangeRedRule();

            [Fact]
            public void return_true_when_changed_from_10_to_13()
            {
                var result = _sut.IsValid(
                    fake,
                    new RPCompanyESGComputationResult { OverallPerformance = new RPPerformance { Score = 13 } });

                Assert.True(result);
            }

            [Fact]
            public void return_false_when_changed_from_10_to_20()
            {
                var result = _sut.IsValid(
                    fake,
                    new RPCompanyESGComputationResult { OverallPerformance = new RPPerformance { Score = 20 } });

                Assert.False(result);
            }
        }

        public class YellowRule_should_ : OverallScore
        {
            private readonly ScoreChangeYellowRule _sut = new ScoreChangeYellowRule();

            [Fact]
            public void return_false_when_changed_from_10_to_13()
            {
                var result = _sut.IsValid(
                    fake,
                    new RPCompanyESGComputationResult { OverallPerformance = new RPPerformance { Score = 13 } });

                Assert.False(result);
            }

            [Fact]
            public void return_true_when_changed_percent_changed_is_17()
            {
                var result = _sut.IsValid(
                    new RPCompanyESGComputationResult { OverallPerformance = new RPPerformance { Score = 56.345f } },
                    new RPCompanyESGComputationResult { OverallPerformance = new RPPerformance { Score = 68.555f } });

                Assert.True(result);
            }
        }
    }
}
